package com.zhuss.product.processor;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

import com.zhuss.bean.bo.product.train.DeleteLineStrategyBo;
import com.zhuss.common.AbstractProcessor;
import com.zhuss.common.Processor;
import com.zhuss.db.entity.OpLog;
import com.zhuss.exception.DzcxException;
import com.zhuss.product.db.dao.ext.LineStrategyDao;
import com.zhuss.util.JsonUtil;

/**
 * @description: 线路策略删除
 * @author: zhushanshuo
 * @create: Mon Jan 04 09:51:07 CST 2021
 **/
@Component("lineStrategyDelete")
public class LineStrategyDelete extends AbstractProcessor<Object, DeleteLineStrategyBo> implements Processor<Object, DeleteLineStrategyBo> {

    @Autowired
    private LineStrategyDao lineStrategyDao;

    @Autowired
	@Qualifier("lineStrategyRead")
	private LineStrategyRead lineStrategyRead;


    /**
     * 校验
     */
	@Override
    public void check(DeleteLineStrategyBo bo) throws DzcxException {
		// TODO 删除 线路策略 校验， 请补充
    }

    /**
     * 操作方法
     */
    @Override
    public Object process(DeleteLineStrategyBo param) throws DzcxException {
//    	Long lineStrategyId = param.getLineStrategyId();
//    	String name = ((DetailLineStrategyVo) lineStrategyRead.detail(lineStrategyId)).getName();
//
//    	LineStrategy record = new LineStrategy();
//    	record.setLineStrategyId(lineStrategyId);
//    	record.setDeleted(param.getDeleted());
//
//    	record.setModifierId(param.getConcurrentUserId());
//    	record.setModifier(param.getConcurrentUserName());
//    	record.setModifyTime(new Date());
//    	lineStrategyDao.delete(record);
//    	param.setName(name);
        return null;
    }

    /**
     * 操作日志
     */
	@Override
	public Object log(DeleteLineStrategyBo param) throws DzcxException {
		OpLog record = new OpLog();
//    	record.setMoudle(MoudleEnum.默认模块请修改.key());
//    	record.setAction(LogActionEnum.线路策略删除.key());
    	record.setTargetId(param.getLineStrategyId());
    	record.setTargetName(param.getName());
    	record.setContent("参数: " + JsonUtil.toJson(param));
    	record.setReason(param.getExceptionReason());

    	record.setCreatorId(param.getConcurrentUserId());
    	record.setCreator(param.getConcurrentUserName());
    	record.setCreateTime(new Date());
    	log(record);
    	return null;
	}
}
